//
//  NSObject+EX.h
//  EasyCar
//
//  Created by nsm on 2017/5/26.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface NSObject (EX)
+ (BOOL)swizzleMethod:(SEL)originalSel withMethod:(SEL)newSel;
- (void)showAlert:(NSString *)message;
@end

@protocol BackBarButtonItemProtocol <NSObject>
@optional
- (BOOL)backBarButtonItemShouldPopBack;
@end

@interface UIViewController (exchange) <BackBarButtonItemProtocol>
- (void)showAlert:(NSString *)message action:(void (^)(UIAlertAction *action))handler completion:(void (^)(void))completion;
- (void)showAlert:(NSString *)message action:(void (^)(UIAlertAction *action))handler;
- (void)showAlert:(NSString *)message cancel:(void (^)(UIAlertAction *action))cancel done:(void (^)(UIAlertAction *action))done;
- (void)showAlert:(NSString *)title message:(NSString *)message action:(void (^)(UIAlertAction *action))done;
- (void)showAlert:(NSString *)title message:(NSString *)message cancel:(void (^)(UIAlertAction *action))cancel done:(void (^)(UIAlertAction *action))done;
@end

@interface NSDictionary (EX)
- (NSString *)printString;
@end

@interface UILabel (EX)
- (void)setTextAlignmentScaleToFill;
@end


typedef NS_OPTIONS(NSUInteger, NSMViewCorner) {
    NSMViewCornerNone           = 0,
    NSMViewCornerUpperLeft      = 1 << 0,
    NSMViewCornerUpperRight     = 1 << 1,
    NSMViewCornerLowerLeft      = 1 << 2,
    NSMViewCornerLowerRight     = 1 << 3,
    NSMViewCornerAll            = (1 << 4) - 1,
};

@interface UIView (EX)
- (void)setCorners:(NSMViewCorner)corners radius:(CGFloat)radius;
@end


@interface UIView (FullSnapshot)
- (UIImage *)fullSnapshot;
@end

@interface NSMButton (Ex)
+ (instancetype)buttonWithTitle:(NSString *)title target:(id)target action:(SEL)action;
@end

@interface UIScrollView (CanScroll)
- (BOOL)canScroll;
@end
